﻿@using ArsenalManagement.Tools
@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
    ViewData["Title"] = "Test";
}

@model PaginatedList<ArsenalManagement.Models.Vehicle>

<h2>Index</h2>
<p>
    <a asp-action="Create">Create New</a>
</p>
 
<form asp-action="Test" method="get">
    <div class="form-actions no-color">
        <p>
            查找: <input type="text" name="SearchString" value="@ViewData["currentFilter"]" />
            <input type="submit" value="Search" class="btn btn-default" /> |
            <a asp-action="Test">Back to Full List</a>
        </p>
    </div>
</form>
 
<table class="table">
    <thead>
        <tr>
            <th>
                <a asp-action="Test" asp-route-sortOrder="@ViewData["NameSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">载具名</a>
            </th>
            <th>
                图片URL
            </th>
            <th>
                <a asp-action="Test" asp-route-sortOrder="@ViewData["InfoSortParm"]" asp-route-currentFilter="@ViewData["CurrentFilter"]">载具简介</a>
            </th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Vehiclename)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.ImgUrl)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Info)
                </td>
                <td>
                    <a asp-action="Edit" asp-route-id="@item.Id">Edit</a> |
                    <a asp-action="Details" asp-route-id="@item.Id">Details</a> |
                    <a asp-action="Delete" asp-route-id="@item.Id">Delete</a>
                </td>
            </tr>
        }
    </tbody>
</table>
 
@{
    var prevDisabled = !Model.HasPreviousPage ? "disabled" : "";
    var nextDisabled = !Model.HasNextPage ? "disabled" : "";
}
 
<a asp-action="Test"
   asp-route-sortOrder="@ViewData["CurrentSort"]"
   asp-route-page="@(Model.PageIndex - 1)"
   asp-route-currentFilter="@ViewData["CurrentFilter"]"
   class="btn btn-default @prevDisabled">
    Previous
</a>
<a asp-action="Test"
   asp-route-sortOrder="@ViewData["CurrentSort"]"
   asp-route-page="@(Model.PageIndex + 1)"
   asp-route-currentFilter="@ViewData["CurrentFilter"]"
   class="btn btn-default @nextDisabled">
    Next
</a>